package cn.hanyx.coder.design.pattern.behavioral.visitor.demo06;

import cn.hanyx.coder.design.pattern.behavioral.visitor.demo06.compressor.Compressor;
import cn.hanyx.coder.design.pattern.behavioral.visitor.demo06.compressor.CompressorFactory;
import cn.hanyx.coder.design.pattern.behavioral.visitor.demo06.extractor.Extractor;
import cn.hanyx.coder.design.pattern.behavioral.visitor.demo06.extractor.ExtractorFactory;
import cn.hanyx.coder.design.pattern.behavioral.visitor.demo06.file.PPTFile;
import cn.hanyx.coder.design.pattern.behavioral.visitor.demo06.file.PdfFile;
import cn.hanyx.coder.design.pattern.behavioral.visitor.demo06.file.ResourceFile;
import cn.hanyx.coder.design.pattern.behavioral.visitor.demo06.file.WordFile;

import java.util.ArrayList;
import java.util.List;

/**
 * ToolApplication
 *
 * @author hanyx
 * @date 2020/07/28
 */
public class ToolApplication {

    public static void main(String[] args) {
        List<ResourceFile> resourceFiles = getFiles();

        for (ResourceFile resourceFile : resourceFiles) {
            Extractor extractor = ExtractorFactory.getExtractor(resourceFile.getType());
            extractor.extract2txt(resourceFile);
        }

        for (ResourceFile resourceFile : resourceFiles) {
            Compressor compressor = CompressorFactory.getCompressor(resourceFile.getType());
            compressor.compressor2txt(resourceFile);
        }
    }

    public static List<ResourceFile> getFiles() {
        List<ResourceFile> resourceFiles = new ArrayList<>();
        resourceFiles.add(new PdfFile("a.pdf"));
        resourceFiles.add(new WordFile("b.word"));
        resourceFiles.add(new PPTFile("c.ppt"));
        return resourceFiles;
    }
}
